package com.guoyu.project.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.google.common.collect.Maps;
import com.guoyu.project.common.pagination.Pagination;
import com.guoyu.project.dao.Project_ManageDao;
import com.guoyu.project.model.Article;
import com.guoyu.project.model.Banner;
import com.guoyu.project.model.Project_Manage;
import com.guoyu.project.model.enums.ArticleType;
import com.guoyu.project.model.enums.ProjectType;

@Service
public class Project_ManageService {

	@Resource
	private Project_ManageDao project_ManageDao;
	
	//添加
    public void saveProject_Manage(Project_Manage project_manage) {
    	project_ManageDao.save(project_manage);;
    }

    //更新
    public void updateProject_Manage(Project_Manage project_manage) {
    	project_ManageDao.update(project_manage);
    }

    /**
     * 删除
     */
    public void deleteById(Integer pId) {
    	project_ManageDao.deleteById(pId);
    }

    /**
     * 根据id获取信息数据
     */
    public Project_Manage queryById(Integer pId) {
    	
    	return project_ManageDao.queryById(pId);
    }

    /**
     * 根据条件分页查询信息数据
     *
     * @param offset
     * @param limit
     * @param params
     * @return
     */
    public Pagination<Project_Manage> queryAllProject_Manage(int offset, int limit, Map<String, Object> params) {
        // 根据条件获取总记录数
        int total = project_ManageDao.queryPMCount(params);

        // 构建分页对象，参数
        if (null == params) {
            params = Maps.newHashMap();
        }
        params.put(Pagination.OFFSET, offset);
        params.put(Pagination.LIMIT, limit);

        // 分页查询数据
        List<Project_Manage> pmList = project_ManageDao.queryAllProject_Manage(params);
        return new Pagination(offset, limit, total, pmList);
    }

    
    public List<Project_Manage> queryAllProject_Manage(Map<String, Object> params) {
        return project_ManageDao.queryAllProject_Manage(params);
    }
    
    public List<Project_Manage> queryAllProject() {
        Map<String, Object> params = Maps.newHashMap();
   
        return project_ManageDao.queryAllProject_Manage(params);
    }
    
    public List<Project_Manage> queryByProjectId(Integer pId) {
        Map<String, Object> params = Maps.newHashMap();
   
        params.put("pId", pId);
        return project_ManageDao.queryAllProject_Manage(params);
    }
    
    
 /*  public Pagination<Project_Manage> queryBypid(){
	   
   }*/
     
}